<?php
  session_start();

  if(!isset($_SESSION['isLogged'])){
    header('Location: index.php');
  }
  $now=time();
  if(isset($_SESSION['isLogged']) && ($now>$_SESSION['expired'])){
    session_unset();
    session_destroy();
    header('Location: index.php');
  }

?>
<div class="container" id="container">
  <div class="panel panel-primary">
      <div class="panel-heading">
          <h3>Proses Usulan</h3>
      </div>
      <div class="panel-body">
        <div class="wm-loader in" style="display:none;" id="loader"><b></b><i></i></div>
        <div class="tabbable">
          <ul class="nav nav-tabs" id="myTab">
            <li><a href="#perusulan" data-toggle="tab">Per Usulan</a></li>
            <li><a href="#perpegawai" data-toggle="tab">Per Pegawai</a></li>
            <li><a href="#selesai" data-toggle="tab">Upload Dokumen</a></li>
          </ul>
        </div>
        <div class="tab-content">
          <div class="tab-pane active" id="perusulan">
            <table cellpadding="0" cellspacing="0" border="0" class="datatable table table-condensed table-bordered table-hover col-lg-offset-0" id="list_usulan">
              <thead>
                  <tr>
                      <th>No Surat</th>
                      <th>Tanggal Surat</th>
                      <th>Jumlah Pegawai</th>
                      <!-- <th>Kanwil</th> -->
                      <th>Dokumen</th>
                      <th>Cek</th>
                  </tr>
              </thead>
              <tbody>
              </tbody>
            </table>
            <form class="form-inline col-lg-offset-0" role="form">
              <!-- <div class="form-group">
              <button type="submit" class="btn btn-default" id="proses_lampiran_usulan_btn">Buat Lampiran</button>
              </div> -->
               <div class="form-group">
              <select id="aksi_proses_usulan" name="aksi_proses_usulan" class="form-control hidden">
              </select>
              </div>
               <div class="form-group">
               <button type="submit" class="btn btn-primary" id="proses_usulan_btn">Terima</button>
               </div>
               
            </form>
          </div>
          <div class="tab-pane" id="perpegawai">
            <table cellpadding="0" cellspacing="0" border="0" class="datatable table table-condensed table-bordered table-hover col-lg-offset-0" id="list_pegawai">
              <thead>
                <tr>
                    <th>NIP</th>
                    <th>Nama</th>
                    <th>Jenis Cuti</th>
                    <th>Jenis Ijin</th>
                    <th>Tanggal Cuti</th>
                    <th>Status</th>
                    <th>Dokumen</th>
                    <th>Cek</th>
                </tr>
              </thead>
              <tbody>
              </tbody>
            </table>
            <form class="form-inline col-lg-offset-4" role="form" id="frm_cetak" action="controller/cont.cetak.php" method="post">
              <input type="hidden" id="cetak_surat_doc2" name="cetak_surat_doc2" />
              <div class="form-group">
              <button type="submit" class="btn btn-success" id="proses_xlx_btn">Print Excel</button>
              </div>
              <div class="form-group">
              <button type="submit" class="btn btn-success" id="proses_doc_btn" onclick="doPrint();">Print Docx</button>
              </div>
              <div class="form-group">
              <button type="submit" class="btn btn-success" id="proses_lampiran_btn">Print PDF</button>
              </div>
              <div class="form-group">
              <select id="aksi_proses" name="aksi_proses" class="form-control">
              </select>
               </div>
              <div class="form-group" >
               <button type="submit" class="btn btn-default" id="proses_btn">Submit</button>
                </div>
            </form>
          </div>
          <div class="tab-pane" id="selesai">
            <form class="form-inline col-lg-offset-0" role="form">
             <div class="form-group">
                <div class="col-lg-16">
                    <select id="jenis_dokumen" name="jenis_dokumen" class="form-control">
                      <option value="">Pilih Jenis Dokumen Yang Akan Diupload</option>
                      <option value="4">Dokumen Pengajuan ke Setjen</option>
                      <option value="6">Dokumen Persetujuan dari Setjen</option>
                    </select>
                 </div>
              </div>
            </form>
            <div class="highlight" id="daftarnya" style="display: none;">
                <table cellpadding="0" cellspacing="0" border="0" class="datatable table table-condensed table-bordered table-hover col-lg-offset-0" id="list_pegawai_filter">
                  <thead>
                    <tr>
                        <th>NIP</th>
                        <th>Nama</th>
                        <th>Jenis Ijin</th>
                        <th>Tanggal Cuti</th>
                        <th>Status</th>
                        <th>Cek</th>
                    </tr>
                  </thead>
                  <tbody>
                  </tbody>
                </table>
                <div id="frm_upload">
                    <form role="form" id="form_upload_dokumen" method="post" enctype="multipart/form-data" class="form-inline col-lg-offset-7">
                        <div class="form-group">
                            <input type="file" id="file_proses" class="form-control " name="file_proses">
                        </div>
                        <div class="form-group">
                            <input class="btn btn-warning btn-sm" type="submit" id="btn_upload_proses" value="Upload">
                        </div>
                    </form>
                </div>
            </div>
          </div>
        </div>
    </div>
  </div>
  <div id="error" class="alert alert-danger">...</div>
  <div id="success" class="alert alert-success">...</div>
</div>

<div id="pdf">
    
</div>
<div class="modal fade" id="myModalUpload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Dokumen</h4>
            </div>
            <div class="modal-body">
                <div id="list_dokumen">
                    <table cellpadding="0" cellspacing="0" border="0" id="list_dokumen" class="datatable table table-condensed table-bordered col-lg-offset-0">
                        <thead>
                            <tr>
                                <th>No</th>
                                <th>Deskripsi</th>
                                <th>Aksi</th>
                            </tr>
                        </thead>
                        <tbody>

                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<script type="text/javascript" src="js/ajaxfileupload.js"></script>
<script type="text/javascript" src="js/proses.js" ></script>

<script type="text/javascript">
function doPrint(){
  var details= new Array();
  $('#selectPeg:checked').each(function () {
      var id = $(this).closest('tr').attr('detailId');
      details.push(id);
      
  });

  if(details.length<=0){
      alert('Pilih dahulu pegawai');
  }else if(details.length>=2){
      alert('Hanya Bisa Satu Orang Pegawai');
  }else{
      document.getElementById("cetak_surat_doc2").value=details;
      $("#frm_cetak").submit();
  }
}
</script>
